package site.microkang.house.restful;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import site.microkang.house.common.ResponseParam;
import site.microkang.house.external.http.GovSocialInsuranceHttpService;
import site.microkang.house.model.dto.TalentIdentificationDto;
import site.microkang.house.model.dto.TalentIdentificationInfoDto;
import site.microkang.house.model.vo.TalentIdentificationParamVo;
import site.microkang.house.service.TalentIdentificationService;

import java.util.List;

/**
 * @author liukang
 * @date 2021/3/19 23:20
 */
@Api(description ="人才认定信息API")
@RestController
@RequestMapping(value = "/v1/talentIdentification")
public class TalentIdentificationRestful {
    @Autowired
    private TalentIdentificationService talentIdentificationService;
    @Autowired
    private GovSocialInsuranceHttpService govSocialInsuranceHttpService;

    /**
     * 获取所有数据
     * @param dto
     * @return
     */
    @ApiOperation("人才认定信息列表")
    @PostMapping(value = "list")
    public ResponseParam<List<TalentIdentificationDto>> list(@RequestBody(required = false) TalentIdentificationDto dto) {
        List<TalentIdentificationDto> dtos = talentIdentificationService.selectList(dto);
        return new ResponseParam<>(200, "操作成功", dtos);
    }

    @ApiOperation("根据excel地址导入并保存人才认定信息")
    @PostMapping(value = "importData")
    public ResponseParam<Boolean> importData(@RequestBody TalentIdentificationParamVo vo) {
        govSocialInsuranceHttpService.xlsFileAnalysisAndSave(vo.getXlsFileUrl());
        return new ResponseParam<>(200, "操作成功", true);
    }

}
